<template>
    <div></div>
</template>
<script setup>
//实现地球的自转 map.easeTo()方法
import { inject, onMounted, onBeforeUnmount } from 'vue'
let map, requestAnimationFrameId
onMounted(() => {
    map = inject('mapScene').map
    map.setZoom(1);
    map.setPitch(0);
    map.setPitch(0)
    map.setBearing(0)
    rotate()
})
function rotate() {
    let center = map.getCenter()
    center.lng += 0.1
    if (center.lng >= 180) {
        center.lng = -180
    }
    //之前实现地球自转用的easeto函数方法 这里推荐使用关键帧来自己实现
    map.setCenter(center)
    requestAnimationFrameId = requestAnimationFrame(rotate)
}
onBeforeUnmount(() => {
    //在这里需要清除动画关键帧id
    cancelAnimationFrame(requestAnimationFrameId)
})
</script>

<style lang="scss" scoped></style>